package com.csmz.web.controller.enterprise;

import com.csmz.common.annotation.Log;
import com.csmz.common.core.controller.BaseController;
import com.csmz.common.core.domain.AjaxResult;
import com.csmz.common.core.page.TableDataInfo;
import com.csmz.common.enums.BusinessType;
import com.csmz.common.utils.poi.ExcelUtil;
import com.csmz.enterprise.domain.CsmzParttimePosition;
import com.csmz.enterprise.service.ICsmzParttimePositionService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 兼职岗位Controller
 * 
 * @author TT
 * @date 2025-09-17
 */
@RestController
@RequestMapping("/enterprise/parttimePosition")
public class CsmzParttimePositionController extends BaseController
{
    @Autowired
    private ICsmzParttimePositionService csmzParttimePositionService;

    /**
     * 查询兼职岗位列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:parttimePosition:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsmzParttimePosition csmzParttimePosition)
    {
        startPage();
        List<CsmzParttimePosition> list = csmzParttimePositionService.selectCsmzParttimePositionList(csmzParttimePosition);
        return getDataTable(list);
    }

    /**
     * 查询我公司发布的兼职岗位列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:parttimePosition:list')")
    @GetMapping("/myList")
    public TableDataInfo myList(CsmzParttimePosition csmzParttimePosition)
    {
        startPage();
        List<CsmzParttimePosition> list = csmzParttimePositionService.selectMyCsmzParttimePositionList(csmzParttimePosition);
        return getDataTable(list);
    }

    /**
     * 导出兼职岗位列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:parttimePosition:export')")
    @Log(title = "兼职岗位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsmzParttimePosition csmzParttimePosition)
    {
        List<CsmzParttimePosition> list = csmzParttimePositionService.selectCsmzParttimePositionList(csmzParttimePosition);
        ExcelUtil<CsmzParttimePosition> util = new ExcelUtil<CsmzParttimePosition>(CsmzParttimePosition.class);
        util.exportExcel(response, list, "兼职岗位数据");
    }

    /**
     * 获取兼职岗位详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:parttimePosition:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(csmzParttimePositionService.selectCsmzParttimePositionById(id));
    }

    /**
     * 新增兼职岗位
     */
    @PreAuthorize("@ss.hasPermi('enterprise:parttimePosition:add')")
    @Log(title = "兼职岗位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsmzParttimePosition csmzParttimePosition)
    {
        return toAjax(csmzParttimePositionService.insertCsmzParttimePosition(csmzParttimePosition));
    }

    /**
     * 新增我公司发布兼职岗位
     */
    @PreAuthorize("@ss.hasPermi('enterprise:parttimePosition:add')")
    @Log(title = "兼职岗位", businessType = BusinessType.INSERT)
    @PostMapping("/myAdd")
    public AjaxResult myAdd(@RequestBody CsmzParttimePosition csmzParttimePosition)
    {
        return toAjax(csmzParttimePositionService.insertMyCsmzParttimePosition(csmzParttimePosition));
    }

    /**
     * 修改兼职岗位
     */
    @PreAuthorize("@ss.hasPermi('enterprise:parttimePosition:edit')")
    @Log(title = "兼职岗位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsmzParttimePosition csmzParttimePosition)
    {
        return toAjax(csmzParttimePositionService.updateCsmzParttimePosition(csmzParttimePosition));
    }

    /**
     * 删除兼职岗位
     */
    @PreAuthorize("@ss.hasPermi('enterprise:parttimePosition:remove')")
    @Log(title = "兼职岗位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(csmzParttimePositionService.deleteCsmzParttimePositionByIds(ids));
    }
}
